home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / confirm.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  6KB  |  224 lines

  1. /*
  2.                    CONFIRM
  3.  
  4.  Function: handle the "confirm" verb processing.
  5.  Input: pointer to "confirm" structure.
  6.  
  7.  CopyRight 1995. Nicholas Poljakov all rights reserved.
  8.  
  9.  */
  10.  
  11.  
  12. #include <stdio.h>
  13. #include <conf.h>
  14. #include <state1.h>
  15. #include <rcb.h>
  16. #include <tcb.h>
  17. #include <lucb.h>
  18. #include <cma.h>
  19. #include <psp.h>
  20. #include <repass.h>
  21. #include <prefix.h>
  22. #include <string.h>
  23. #include <malloc.h>
  24.  
  25. int sk_r_wt(void *);
  26. int SendBlock(void *, void *);
  27. int setrc(void *, void *);
  28. int sendhsf(void *);
  29. int sendhs(void *);
  30. int sendbm(void *, void *);
  31. int sendat(void *);
  32. int rtsend(void *);
  33. unsigned long rmfmh5(void *, void *);
  34. int rcvru(void *, void *);
  35. int rcvhs(void *, void *, void *, void *);
  36. int ralloc(void *, void *);
  37. int psrm(int, void *, void *);
  38. int ps_conv(int, void *);
  39. int proterr(void *, unsigned long);
  40. int preptrcv(void *, void *);
  41. int post_rcb(void *);
  42. struct repass *postopen(void *);
  43. int phsrec(void *);
  44. int pfmh5(void *);
  45. int opndst(void *);
  46. int obtsess(void *, unsigned char);
  47. int Lrf_handler(void *);
  48. int get_sess(void *, void *);
  49. int get_attr(void *);
  50. int fsm_error(unsigned char, void *);
  51. int fsm_conv(unsigned char, unsigned char, void *);
  52. int flush (void *);
  53. int dcp(void *);
  54. int dealloc(void *);
  55. int crtp(void *);
  56. int conv(void *);
  57. int chkparm(void *, void *);
  58. int check_end(unsigned int, void *);
  59. struct rqb *call_appl(void *);
  60. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  61. unsigned long attltck(void *);
  62. unsigned long attacheck(void *);
  63. char *cgetmem(int, int);
  64. int sendhsf(void *);
  65. int opndst(void *);
  66. int alloc_rcb(void *, void *);
  67. int allocate(void *);
  68. int clsdst(void *);
  69.  
  70. confirm(pptr)
  71. struct confirm *pptr;
  72. {
  73. extern struct psp psp_ini;
  74. struct rcb *p_rcb;
  75. struct repass *p_rep;
  76. struct tcb *ptr_tcb;
  77. struct lucb *ptr_lucb;
  78. struct prefix *p_prf;
  79. struct prefix *t_prf;
  80. struct cma ar;
  81. unsigned char type;
  82. char *p;
  83. char *pl;
  84. char p1;
  85.  
  86. int code;
  87. int state;
  88.  
  89. #if OS_TYPE == 1 /* Unix System V */
  90. /*********  Trace facility **********/
  91. unsigned int rtype;   /* type of record */
  92. unsigned int pnum;    /* point number */
  93. char pname[8];        /* name of module */
  94. char *drec;       /* record for dump */
  95. int  lenr;            /* record length */
  96.  
  97. rtype = INPROC;
  98. strcpy(pname, "conf");
  99. pnum = 1;
  100. drec = pptr;
  101. lenr = sizeof(struct confirm);
  102. gtf(rtype, pname, pnum, drec, lenr);
  103. /***********************************/
  104. #endif
  105.  
  106.        if (chkparm(pptr, &ar) == -1) {
  107.           return(0);
  108.        }
  109.        p_rcb = ar.p_rcb;
  110.        ptr_tcb = ar.p_tcb;
  111.  
  112.        p_rep = (struct repass *)pptr;
  113.  
  114.        if (p_rep -> complete == 1) {
  115.              goto WaitCfd;
  116.        }
  117.  
  118.     /*   ó  RCB  ºá¡«ß¿¼ ¬«ñ »α¿¼¿Γ¿óá  */
  119.        p_rcb ->verb_code = pptr -> code;
  120.        p_rcb -> verb_ptr = (char *)pptr;
  121.  
  122.        pptr -> rts = No;
  123.        pptr -> prim_rc = 0;
  124.        pptr -> sec_rc = 0;
  125.  
  126.        if ((state = fsm_conv('s', Confirm, p_rcb)) == -1)
  127.             {
  128.                 pptr -> prim_rc = PORT_ABENDED;
  129.         return 0;
  130.             }
  131.        if (state == 1)
  132.             {
  133.                 pptr -> prim_rc = PORT_ABENDED;
  134.         return 0;
  135.             }
  136.        else
  137.            {
  138.                switch (p_rcb->error_state)   {
  139.  
  140.                  case CONV_FAILURE_PROTOCOL_ERROR:
  141.                       {
  142.                         pptr->prim_rc = RESOURCE_FAILURE_NO_RETRY;
  143.                         fsm_conv('r',RESOURCE_FAILURE_RC,p_rcb);
  144.                         break;
  145.                       }
  146.                  case CONV_FAILURE_SON:
  147.                       {
  148.                          pptr->prim_rc=RESOURCE_FAILURE_RETRY;
  149.                          fsm_conv('r',RESOURCE_FAILURE_RC,p_rcb);
  150.                          break;
  151.                       }
  152.                  case ALLOCATE_FAILURE_RETRY:
  153.                  case ALLOCATE_FAILURE_NO_RETRY:
  154.                  case SYNC_LEVEL_NOT_SUPPORTED:
  155.                       {
  156.                          pptr->prim_rc = ALLOCATION_ERROR;
  157.                          if(p_rcb->error_state == ALLOCATION_FAILURE_RETRY)
  158.                          pptr->sec_rc = ALLOCATION_FAILURE_RETRY;
  159.                          if(p_rcb->error_state == ALLOCATION_FAILURE_NO_RETRY)
  160.                             {
  161.                                pptr->sec_rc = ALLOCATION_FAILURE_NO_RETRY;
  162.                             }
  163.                          else
  164.                             {
  165.                                pptr->sec_rc = SYNC_LEVEL_NOT_SUPPORTED_BY_LU;
  166.                             }
  167.                          fsm_conv('r',ALLOCATION_ERROR_RC,p_rcb);
  168.                          break;
  169.                       }
  170.                  case RCVD_ERROR:  break;   /* This will be correct later! */
  171.  
  172.                  case NO_RQS:  {
  173.                         switch (p_rcb -> conv_state) {
  174.                 case SEND : type = Confirm;
  175.                                             break;
  176.                                 case pend_deall : type = Deallocate_confirm;
  177.                         }
  178.                         buffmng('A', NULL, NULL, p_rcb, 0, 0, type);
  179.                         sendhsf(p_rcb);
  180.                  }
  181.             }
  182.      } /* else (for conv_state check ) */
  183.  
  184.      p_rep -> complete = 1; /* req. to retry */
  185.      p_rep -> p_rcb = p_rcb;
  186.      return (0);
  187.  
  188. WaitCfd:  /* Wait for the Confirmed verb from the Partner */
  189.  
  190.      /* Search for the last element in the input queue
  191.       * and test if it's "Confirmed", if so
  192.       * delete it and continue execution.
  193.       */
  194.      p_prf = p_rcb -> first_in;
  195.      while (p_prf -> next != NULL) ;
  196.      if ((p_prf -> type == COnfirmed) || (p_prf -> type == Request_to_send)) {
  197.  
  198.         /* Delete the element with "Confirmed" command
  199.          * from the input queue.
  200.          */
  201.         t_prf = p_prf -> prev;
  202.         free( p_prf );
  203.         if (t_prf == NULL) {
  204.            p_rcb -> first_in = NULL;
  205.         }
  206.         else
  207.            t_prf -> next = NULL;
  208.  
  209.         if (p_prf -> type == Request_to_send) {
  210.            pptr -> rts = YES;
  211.            goto WaitCfd;
  212.         }
  213.      }
  214.      else
  215.            goto WaitCfd;
  216.  
  217.      if (p_rcb -> first_in == NULL) {
  218.         p_rcb -> hsps = No;
  219.      }
  220.      p_rep -> complete = 0; /* Function completed */
  221.  
  222.      return 0;
  223. }
  224.